package com.cysyz.mylib.utils.init;

import com.cysyz.mylib.utils.myassert.MyAssert;
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Method;

public enum DataType {
	BYTE(Byte.class), SHORT(Short.class), INT(Integer.class), LONG(Long.class), FLOAT(Float.class), DOUBLE(Double.class), STRING(String.class);
	private Class clazz;
	
	private DataType(Class clazz) {
		this.clazz = clazz;
	}
	
	public Class getDataTypeClass() {
		return clazz;
	}
	
	public Method getSetter(Object bean, String setterName) {
		MyAssert.notNull(bean);
		MyAssert.hasText(setterName);
		
		Method setterMethod = ReflectionUtils.findMethod(bean.getClass(), setterName, this.clazz);
		
		MyAssert.notNull(setterMethod);
		return setterMethod;
	}


}
